<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>酒店信息</title>
		<link href="../mui/css/mui.min.css" rel="stylesheet" />
		<link href="../styles/default.css" rel="stylesheet" />
		<style>
			.mui-bar-nav~.mui-content {
				padding-top: 6.4rem;
			}
			
			.mui-content {
				margin-bottom: 6.6rem;
			}
			
			.mui-content>.mui-table-view:first-child {
				margin-top: 0;
			}
			
			.mui-content li:last-child {
				padding-bottom: 1.5rem;
			}
			
			.mui-table-view-cell {
				padding: 0.75rem 1.2rem;
			}
			
			.mui-table-view-cell:first-child {
				padding-top: 1.2rem;
			}
			
			.mui-table-view-cell:last-child {
				padding-bottom: 1.2rem;
			}
			
			.mui-bar {
				height: 6.4rem;
				padding-top: 2rem;
				display: flex;
				align-items: center;
			}
			
			.mui-navigate-right:after,
			.mui-push-right:after {
				right: inherit;
			}
			
			.mui-bar a {
				position: relative;
			}
			
			.mui-indexed-list {
				width: 78%;
				border-radius: 0.5rem;
				border: 1px solid #ccc;
			}
			
			.mui-indexed-list-search {
				border: none;
			}
			
			.mui-bar input[type=search] {
				margin: 0;
			}
			
			.mui-bar .mui-icon {
				padding: 0;
			}
			
			.mui-search .mui-placeholder {
				height: 3rem;
				font-size: 1rem;
				line-height: 3rem;
			}
			
			.mui-search .mui-placeholder .mui-icon {
				font-size: 1.6rem;
				margin: 0;
			}
			
			.mui-bar-nav.mui-bar .mui-icon {
				padding-right: 0.5rem;
				padding-left: 0.5rem;
			}
			
			.hotel-footer {
				position: absolute;
				border: none;
				border-bottom: 1px solid #ddd;
				background-color: #f7f7f7;
				top: 4.4rem;
				height: 4rem;
			}
			
			.hotel-footer-menu {
				display: flex;
				text-align: center;
			}
			
			.hotel-footer-menu li {
				padding-top: 0;
			}
			
			.hotel-list {
				display: flex;
				flex-direction: row;
				align-items: center;
				/*justify-content: space-between;*/
			}
			
			.hotel-list-img {
				position: relative;
				width: 7.5rem;
				height: 7.5rem;
				margin-right: 0.9rem;
			}
			
			.hotel-list-img img {
				width: 7.5rem;
				height: 7.5rem;
				vertical-align: middle;
				border-radius: 0.4rem;
			}
			
			.hotel-list-info {
				display: flex;
				flex-direction: column;
				width: 50%;
			}
			
			.info-title {
				font-size: 1.6rem;
				color: #333;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				-webkit-line-clamp: 1;
			}
			
			.info-font-12 {
				font-size: 1.2rem;
				color: #666;
			}
			
			.summary {
				color: #e61874;
				padding: 0.9rem 0;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				-webkit-line-clamp: 1;
			}
			
			.score {
				padding-bottom: 0.6rem;
			}
			
			.address {
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				-webkit-line-clamp: 1;
			}
			
			.hotel-list-price {
				width: 20%;
				font-size: 0;
				text-align: right
			}
			
			.hotel-list-price .sign {
				font-size: 1rem;
				color: #e61874;
			}
			
			.hotel-list-price .hotel-price {
				font-size: 1.4rem;
				color: #e61874;
			}
			
			.hotel-list-price .start {
				font-size: 1.2rem;
				color: #666;
			}
			
			.mui-table-view:before,
			.mui-table-view:after {
				background-color: transparent;
			}
			
			.mui-table-view-cell:after {
				left: 0;
				background-color: transparent;
			}
			
			.mui-input-row {
				font-size: 1.4rem;
				background-color: #fff;
				padding: 0 1.2rem;
			}
			
			.hotel-fixed-area {
				display: flex;
				align-items: center;
				justify-content: flex-end;
			}
			
			.hotel-fixed-area img {
				width: 50%;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav hotel-header">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">酒店推荐</h1>
		</header>

		<div class="mui-content">
			<ul class="mui-table-view mui-content-body" id="recommmend">
				<li class="mui-table-view-cell hotel-list">
					<div class="hotel-list-img">
						<img src="../styles/images/avatar-icon2.png" />
					</div>
					<div class="hotel-list-info">
						<span class="info-title">南国连锁酒店</span>
						<span class="info-font-12 summary">爱爱情趣好去处，嗨翻天</span>
						<span class="info-font-12 score">4.8分 | 非常棒</span>
						<span class="info-font-12 address">距您2.9公里</span>
					</div>
					<div class="hotel-list-price">
						<span class="sign">￥</span>
						<span class="hotel-price">8</span>
						<span class="start">起</span>
					</div>
					<div class="hotel-fixed-area">
						<img src="../styles/images/go-icon.png" />
					</div>
				</li>
				<li class="mui-table-view-cell hotel-list">
					<div class="hotel-list-img">
						<img src="../styles/images/avatar-icon2.png" />
					</div>
					<div class="hotel-list-info">
						<span class="info-title">南国连锁酒店</span>
						<span class="info-font-12 summary">爱爱情趣好去处，嗨翻天</span>
						<span class="info-font-12 score">4.8分 | 非常棒</span>
						<span class="info-font-12 address">距您2.9公里</span>
					</div>
					<div class="hotel-list-price">
						<span class="sign">￥</span>
						<span class="hotel-price">298</span>
						<span class="start">起</span>
					</div>
					<div class="hotel-fixed-area">
						<img src="../styles/images/go-icon.png" />
					</div>
				</li>
				<li class="mui-table-view-cell hotel-list">
					<div class="hotel-list-img">
						<img src="../styles/images/avatar-icon2.png" />
					</div>
					<div class="hotel-list-info">
						<span class="info-title">南国连锁酒店</span>
						<span class="info-font-12 summary">爱爱情趣好去处，嗨翻天</span>
						<span class="info-font-12 score">4.8分 | 非常棒</span>
						<span class="info-font-12 address">距您2.9公里</span>
					</div>
					<div class="hotel-list-price">
						<span class="sign">￥</span>
						<span class="hotel-price">298</span>
						<span class="start">起</span>
					</div>
					<div class="hotel-fixed-area">
						<img src="../styles/images/go-icon.png" />
					</div>
				</li>
			</ul>
		</div>

		<script src="../mui/js/mui.min.js"></script>
		<script src="../libs/ems.js" data-main='./city.js'></script>

		<script type="text/javascript">
			mui.init({
				preloadPages: [{
					id: 'hotel-detail2.html',
					url: 'hotel-detail2.html'
				}],
				swipeBack: true //启用右滑关闭功能
			});

			// 向酒店详情页传值
			var hotelDetailPage = null;
			// 添加列表项的点击事件
			mui('#recommmend').on('tap', '.mui-table-view-cell', function(event) {
				var hotelid = this.getAttribute('id'); // 获取酒店id
				var hotelImgSrc = this.children[0].children[0].getAttribute('src'); // 获取酒店图片
				var hotelDistance = this.children[1].children[3].innerHTML; // 获取酒店距离
				// 获得酒店详情页
				if(!hotelDetailPage) {
					hotelDetailPage = plus.webview.getWebviewById('hotel-detail2.html');
				}
				// 触发详情页的hdID事件
				mui.fire(hotelDetailPage, 'hdID', {
					id: hotelid,
					src: hotelImgSrc,
					distance: hotelDistance
				});
				// 打开酒店详情页面
				mui.openWindow({
					id: 'hotel-detail2.html',
					show: {
						autoShow: true
					}
				});
			});

			mui.plusReady(function() {
				var recommmend = document.getElementById("recommmend");
				mui.ajax('http://www.aiai.com/api/recom', {
					dataType: 'json', //服务器返回json格式数据 
					type: 'get', //HTTP请求类型
					success: function(data) {
						// console.log(JSON.stringify(data));
						//获得服务器响应
						var html = "";
						var rArr = localStorage.getItem('recomArr').split(",");
						var regEx = /(^\s*)|(<[^>]*>)/g;
						for(var i = 0; i < data.length; i++) {
							html += '<li id="' + data[i].hotelid + '" class="mui-table-view-cell hotel-list">';
							html += '<div class="hotel-list-img"><img src="' + data[i].appearancepicurl + '" /></div>';
							html += '<div class="hotel-list-info"><span class="info-title">' + data[i].hotelchnname + '</span>';
							html += '<span class="info-font-12 summary">' + data[i].hotelintroduce.replace(regEx, "") + '</span>';
							html += '<span class="info-font-12 score">' + data[i].commentscore + '分 | ';
							if(data[i].commentscore >= 3 && data[i].commentscore < 4.0) {
								scoreText = "一般";
							} else if(data[i].commentscore >= 4.0 && data[i].commentscore < 4.5) {
								scoreText = "不错";
							} else if(data[i].commentscore >= 4.5 && data[i].commentscore < 4.8) {
								scoreText = "很好";
							} else if(data[i].commentscore >= 4.8 && data[i].commentscore < 5) {
								scoreText = "非常棒";
							} else {
								scoreText = "完美";
							}
							html += '<span>' + scoreText + '</span></span>';
							html += '<span class="info-font-12 address">距您' + rArr[i] + '公里</span></div>';
							html += '<div class="hotel-list-price"><span class="sign">￥</span>'
							html += '<span class="hotel-price">' + data[i].saleprice + '</span>';
							html += '<span class="start">起</span></div>';
							html += '<div class="hotel-fixed-area"><img src="../styles/images/go-icon.png" /></div></li>';
						}
						recommmend.innerHTML = html;
					}
				});
			});
		</script>
	</body>

</html>